"""
Debug 400 error - check exact response
"""
import requests
import json

print("=" * 70)
print("Debug 400 Error - Create Conversation")
print("=" * 70)

url = "https://agent.swjtu.edu.cn/api/proxy/api/v1/create_conversation"
headers = {
    "Apikey": "d4615q1b696dhcjo9u20",
    "Content-Type": "application/json"
}

payload = {
    "UserID": "test_debug",
    "Inputs": {
        "system": "你是一位智能批阅助手。"
    }
}

print(f"\nURL: {url}")
print(f"Headers: {json.dumps(headers, indent=2)}")
print(f"Payload: {json.dumps(payload, indent=2, ensure_ascii=False)}")

response = requests.post(url, json=payload, headers=headers, verify=False)

print(f"\nStatus Code: {response.status_code}")
print(f"Response Headers: {dict(response.headers)}")
print(f"Response Body:")
print(response.text)

if response.status_code != 200:
    try:
        error_data = response.json()
        print(f"\nError Data (JSON):")
        print(json.dumps(error_data, indent=2, ensure_ascii=False))
    except:
        print("Could not parse as JSON")

print("\n" + "=" * 70)
